package com.example.weatherforecast.whtrcdn.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.android.volley.Request
import com.android.volley.Response
import com.android.volley.VolleyError
import com.android.volley.toolbox.StringRequest
import com.example.weatherforecast.net.MyVolleyQueue

open class BaseFragment(private val contentLayoutId: Int) : Fragment(contentLayoutId), Response.Listener<String>, Response.ErrorListener{

    private val cityId = "101010100"

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        return inflater.inflate(contentLayoutId, container, false)
    }

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)

        // 请求网络数据
//        val url = "http://wthrcdn.etouch.cn/WeatherApi?citykey=$cityId"
//        val myVolley = MyVolleyQueue.getMyVolleyQueueInstance(requireContext())
//        val request = StringRequest(
//            Request.Method.GET, url, this, this)
//        myVolley?.addRequest(request)

    }

    override fun onResponse(response: String?) {

    }

    override fun onErrorResponse(error: VolleyError?) {

    }

}